/ Assembly List / LJCTextDataReaderLib / TextDataReader / LJCSetFields

Namespace - LJCTextDataReaderLib


Parameters
layoutFileName - The layout XML file name.

Syntax

C#
public Void LJCSetFields(String layoutFileName)

Sets the DataFields layout from an XML file. (E)

Example

C#
// File Contents
// FirstName, LastName
// John, Doe
// Jane, Doe
        
using LJCTextDataReaderLib;

// The input file does not have a data configuration heading line.
// The hasHeadingLine defaults to true if the parameter is not included.
bool hasHeadingLine = false;
TextDataReader textReader = new TextDataReader(hasHeadingLine);

// The field delimiter defaults to "," if the parameter is not included.
textReader.LJCSetFile("InputFileSpec.txt");
      
// The data field definition are set from a configuration file.
textReader.LJCSetFields("DataFieldConfig.xml");

while(textReader.Read())
{
  // Get the current line values as strings.
  for int index = 0; index < textReader.FieldCount; index++)
  {
    string data = textReader.GetString(index);
  }
}

Copyright © Lester J. Clark and Contributors.
Licensed under the MIT License.